UserScriptをbundleするDeno script
2021-06-05 13:20:32 projectごとにscriptを生成するのが面倒になってきたので、まとめてjson fileを作れるscriptを書いてみましたtakker.icon
汎用的には書いてないです
bundle対象のファイルパスやjsonの形式をいじれば、別のprojectのbundleにも使えるはず
思って作ったというより以前作ったのを少し整理した
ありがたいyosider.icon
コードを変更する場合はコピペするしかない?
しかないですね
サイズが大きいと変更がちょっと大変
少しずつ旧コードを消してから、新しいコードを貼り付ける
貼り付けるのが面倒になってきたtakker.icon
2021-05-26 20:03:56 適当に書いて作った
試しに↓を実行したら動いたので、publicになっていることに気づきましたtakker.icon
privateだとnetwork errorが発生する
なるほど〜
実験台にされてて草
他の人のを実験台にした後だからセーフ()
e.g.
code:sh
Denoさえ入れておけば設定ファイルなしにbundleできるのほんと楽takker.icon externalの相対パスは/takker内を指している?yosider.icon 完全にただの文字列判定ですtakker.icon
import {...} from 'xxx'のxxxが--externalに指定した文字列と一致した場合、そのmoduleをbundleから除外する
へえ〜
除外して動くんでしょうか…?yosider.icon
自分のprojectになければ動きませんtakker.icon
今回の例では、既に../preact@10.5.13/script.jsと../preact@10.5.13/hooks.jsと../htm@3.0.4/preact/script.jsと../scrapbox-dom-accessor/script.jsが/yosider-scriptsにあることを確認したので、除外してみました もちろん入れても構いません
なるほどyosider.icon
ローカルで実行すれば動くんでしょうか?yosider.icon
localで動かせるcodeをbundleした場合はもちろん動かせると思いますtakker.icon
えーと、このdenoコマンドをどこで実行すればいいんでしょうかという意図ですyosider.icon
CLIです(terminal)
さてdeno入れるかyosider.icon
コマンド一発で入るtakker.icon
すぐ入ったyosider.icon
/emoji/tada.icontakker.icon
なんかエラーでたyosider.icon
code:txt
error: Uncaught (in promise) PermissionDenied: Requires net access to "registry.npmjs.org", run again with the --allow-net flag
at deno:core/core.js:86:46
at unwrapOpResult (deno:core/core.js:106:13)
at Object.opSync (deno:core/core.js:120:12)
at opFetch (deno:extensions/fetch/26_fetch.js:40:17)
at mainFetch (deno:extensions/fetch/26_fetch.js:133:44)
at fetch (deno:extensions/fetch/26_fetch.js:296:28)
そうだった"registry.npmjs.orgにもアクセスするんだったtakker.icon
command更新しました
てか普通にdomain指定せず--allow-netだけでもいいか
Denoだと予め指定した権限でしか動かないという安全装置がついている
userのしらないところでこっそりserverにアクセスして個人情報を送ったりできない
Node.jsだと、悪意のあるpackageがやばいサーバーにデータを送信したとしても気づくことができない
/icons/感謝.icon
生成物が見当たらないwyosider.icon
クリップボードにあるはず?だけどない
xsel使えなかったらpbcopyにするとかtakker.icon
ファイル出力したらいけた
dynamic importに相対パスを使っているとうまくコードが動かなくなることに気づいたtakker.icon
esbuildがdynamic importの名前解決に対応していない
workerのソースも同様
↓のコードは大丈夫っぽい
相対パスでdynamic importしてる気がするけどいいのかなyosider.icon
./で同じページ内のファイルを指定していたときに事故る
なるほど
なんかbundleしてimportしたほうが個別にimportするより明らかに読み込み速いwyosider.icon
6秒→2秒くらいになった
はやいtakker.icon
自分はbundleなしで30秒かかってるなーtakker.icon
ひえ〜wyosider.icon
やっぱりそうかーtakker.icon
自分もやりたいけど、dynamic importしまくりだからやりづらい
工夫すればうまくできるかな
やってみた。スゴイハヤクナッタ!takker.icon
一瞬で読み込みが終わって草
いえーい/emoji/tada.iconyosider.icon
fetchの数が減るから、serverの負荷も減りそう
いろいろ感謝ですyosider.icon
/icons2/Your welcome!.iconなのですtakker.icon
複数ファイルを一緒にbundleすることはできるんでしょうかyosider.icon
UserCSSも一緒にbundleできる?
でも読み込み側がstyle.cssじゃないといけないから結局わけることになるか
UserScript.icon
結果
code:js
var Zt=Object.create,E=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var se=e=>E(e,"__esModule",{value:!0});var h=(e,t)=>()=>(e&&(t=e(e=0)),t),_=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),V=(e,t)=>{for(var n in t)E(e,n,{get:tn,enumerable:!0})},y=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!re.call(e,r)&&r!=="default"&&E(e,r,{get:()=>tr,enumerable:!(n=te(t,r))||n.enumerable});return e},L=e=>y(se(E(e!=null?Zt(ne(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);function k({text:e,cursor:t}){let n=()=>window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1;if(t.focus(),n()){let r=t.selectionStart;t.setRangeText(e),t.selectionStart=t.selectionEnd=r+e.length;let i=document.createEvent("UIEvent");i.initEvent("input",!0,!1),t.dispatchEvent(i)}else document.execCommand("insertText",!1,e)}var P=h(()=>{});async function pt({tweetUrl:e}={}){if(!window.getTweetInfo){alert('Please install "getTweetInfo" from https://scrapbox.io/api/code/yosider-scripts/URL\u304B\u3089tweet\u3092\u5F15\u7528\u3059\u308BUserScript/tamperMonkey.js');return}try{let t=await window.getTweetInfo(https://publish.twitter.com/oembed?url=${e}).then(a=>a.response),n=document.createElement("div");n.insertAdjacentHTML("beforeend",t.html);let r=n.getElementsByTagName("blockquote")?.0,i,s,o=...r?.childNodes;return i?.getElementsByTagName("a")?.forEach(a=>a.innerHTML=[${a.href} ${a.textContent}]),i?.getElementsByTagName("br")?.forEach(a=>a.innerHTML=` ),{author:{name:t.author_name,url:t.author_url},content:i?.textContent.split(
),signature:s?.textContent,date:{href:o?.href,text:o?.textContent}}}catch(t){console.error(t)}}var dt=h(()=>{});async function mt(e,t){let n=/https:\/\/twitter\.com\S+\/status\/\d+(?:\?s=\d+)?/g,r=e.match(n)??[];if(r.length===0)return;let i=(await Promise.all(r.map(a=>pt({tweetUrl:a})))).map(a=>le({tweetInfo:a,indent:t})),s={};for(let a of r){let c=r.indexOf(a);if(!i[c])break;s[a]=i[c]}return e.replace(n,a=>s[a]??a)}function le({tweetInfo:e,indent:t}){return[...e.content.filter(r=>r!=="").map(r=>${t}>${r}),${t}>${e.signature}${e.date.href} ${e.date.text}].join( )}var ft=h(()=>{dt()});var ue={};var ht=h(()=>{P();ft();scrapbox.PopupMenu.addButton({title:"\uF099",onClick:e=>{if(!/https:\/\/twitter\.com\S+\/status\/\d+/.test(e))return;let t=document.getElementById("text-input");return Promise.all(e.split(
).map(n=>{let r=n.match(/^\s+|.*/g),i=/^\s+$/.test(r[0])?r[0]:"",s=/^\s+$/.test(r[0])?r[1]:r[0];return console.log([i,s]),mt(s,i)})).then(n=>k({text:n.join(
),cursor:t})),""}})});var gt=_(()=>{scrapbox.PopupMenu.addButton({title:"\uF127",onClick:e=>{let t=e.split(/\n/).map(n=>n.replace(/\[([^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~][^\[\]]*)\]/g,"$1")).join(
);if(e!=t)return t}})});var bt=_(()=>{var pe="button2.js";document.getElementById("editor").addEventListener("click",e=>{let t=e.target;if(!(t.tagName==="IMG"&&t.classList.contains("icon")&&t.title.endsWith("-button")))return;e.preventDefault(),e.stopImmediatePropagation();let n=encodeURIComponent(t.title);import(/api/code/${scrapbox.Project.name}/${n}/${pe}).then(({execute:r})=>{r()}).catch(r=>console.error(r))})});var yt={};V(yt,{execute:()=>de});async function de(e=[]){let t=[...new Set([...e])].filter(n=>n!==scrapbox.Project.name);scrapbox.PageMenu.addMenu({title:xt,image:"https://gyazo.com/54226f0588bb63aa3ff505fad0af824a/raw",onClick:async()=>{let n=scrapbox.PageMenu(xt);n.removeAllItems(),n.emitChange(),!(await Promise.all(t.map(i=>me(i,n)))).some(i=>i)&&n.addItem({title:"No page found.",onClick:()=>{}})}})}async function me(e,t){let n=await fetch(/api/pages/${e}/${scrapbox.Page.title});if(!n.ok)return!1;let{lines:r}=await n.json();return r.length<3&&!r[1]?.text?!1:(t.addItem({title:/${e}/${scrapbox.Page.title},onClick:()=>window.open(https://scrapbox.io/${e}/${scrapbox.Page.title})}),!0)}var xt,wt=h(()=>{xt="OtherProjects"});var Et=_(()=>{var vt="exec code",Ct="https://i.gyazo.com/b12404a0c17e0808af3c8366419073b2.png";scrapbox.PageMenu.addMenu({title:vt,image:Ct,onClick:()=>{let e=scrapbox.PageMenu(vt);e.removeAllItems(),he().forEach(n=>e.addItem({title:n,image:Ct,onClick:()=>fe(n)}))}});async function fe(e){let t=await(await fetch(/api/code/${scrapbox.Project.name}/${scrapbox.Page.title}/${e})).text();(0,eval)(t)}function he(){let e=new Set;return scrapbox.Page.lines.forEach(t=>{t?.codeBlock?.lang==="js"&&t.codeBlock.filename&&e.add(t.codeBlock.filename)}),e}});function It(e){var t=$t.get(this);return t||(t=new Map,$t.set(this,t)),(t=kt(this,t.get(e)||(t.set(e,t=function(n){for(var r,i,s=1,o="",a="",c=[0],l=function(u){s===1&&(u||(o=o.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?c.push(0,u,o):s===3&&(u||o)?(c.push(3,u,o),s=2):s===2&&o==="..."&&u?c.push(4,u,0):s===2&&o&&!u?c.push(5,0,!0,o):s>=5&&((o||!u&&s===5)&&(c.push(s,0,o,i),s=6),u&&(c.push(s,u,0,i),s=6)),o=""},d=0;d<n.length;d++){d&&(s===1&&l(),l(d));for(var p=0;p<n[d].length;p++)r=n[d][p],s===1?r==="<"?(l(),c=[c],s=3):o+=r:s===4?o==="--"&&r===">"?(s=1,o=""):o=r+o[0]:a?r===a?a="":o+=r:r==='"'||r==="'"?a=r:r===">"?(l(),s=1):s&&(r==="="?(s=5,i=o,o=""):r==="/"&&(s<5||n[d][p+1]===">")?(l(),s===3&&(c=c[0]),s=c,(c=c[0]).push(2,0,s),s=0):r===" "||r===" "||r=== ||r==="\r"?(l(),s=2):o+=r),s===3&&o==="!--"&&(s=4,c=c[0])}return l(),c}(e)),t),arguments,[])).length>1?t:t[0]}var kt,$t,jt=h(()=>{kt=function(e,t,n,r){var i;t[0]=0;for(var s=1;s<t.length;s++){var o=t[s++],a=t[s]?(t[0]|=o?1:2,n[t[s++]]):t[++s];o===3?r[0]=a:o===4?r[1]=Object.assign(r[1]||{},a):o===5?(r[1]=r[1]||{})[t[++s]]=a:o===6?r[1][t[++s]]+=a+"":o?(i=e.apply(a,kt(e,a,n,["",null])),r.push(i),a[0]?t[0]|=2:(t[s-2]=0,t[s]=i)):r.push(a)}return r},$t=new Map});var m={};V(m,{html:()=>v});import{h as ge}from"../preact@10.5.13/script.js";import*as Qn from"../preact@10.5.13/script.js";var v,I=h(()=>{jt();y(m,Qn);v=It.bind(ge)});var Mt,_t,Lt=h(()=>{Mt="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.3/katex.min.js",_t=()=>new Promise((e,t)=>{if(document.querySelector(scriptsrc="${Mt}")){e();return}let n=document.createElement("script");n.addEventListener("load",()=>e()),n.addEventListener("error",r=>t(r)),n.src=Mt,document.head.appendChild(n)})});import{useState as Bt,useRef as be,useEffect as xe}from"../preact@10.5.13/hooks.js";var Ot,Pt=h(()=>{Lt();Ot=e=>{let t=be(null),[n,r]=Bt(e),[i,s]=Bt(void 0);return xe(()=>{(async()=>{await _t();try{katex.render(n,t.current),s(void 0)}catch(o){o instanceof katex.ParseError&&s(o.message)}})()},[n,t,s]),{ref:t,formula:n,error:i,setFormula:r}}});import{useRef as x,useState as ye,useEffect as St,useMemo as we,useCallback as ve}from"../preact@10.5.13/hooks.js";function Ce(e,t){var n,r=null,i=x(null),s=x(null),o=ve(function(d){s.current=d,l()},[]),a=x(null),c=x(),l=function(){var p=null;s.current?p=s.current:i.current?p=i.current:t instanceof HTMLElement&&(p=t),a.current!==p&&(c.current&&(c.current(),c.current=null),a.current=p,p&&(c.current=e(p)))};return t&&!(t instanceof HTMLElement)&&(r=t),St(function(){r&&(i.current=r.current),l()},[r,(n=r)==null?void 0:n.current,t]),o}function Ee(e){e===void 0&&(e={});var t=e.onResize,n=x(void 0);n.current=t;var r=x(),i=ye({width:void 0,height:void 0}),s=i[0],o=i[1],a=x(!1);St(function(){return function(){a.current=!0}},[]);var c=x({width:void 0,height:void 0}),l=Ce(function(d){return r.current||(r.current=new ResizeObserver(function(p){if(!!Array.isArray(p)&&!!p.length){var u=p[0],f=Math.round(u.contentRect.width),g=Math.round(u.contentRect.height);if(c.current.width!==f||c.current.height!==g){var b={width:f,height:g};n.current?n.current(b):(c.current.width=f,c.current.height=g,a.current||o(b))}}})),r.current.observe(d),function(){r.current&&r.current.unobserve(d)}},e.ref);return we(function(){return{ref:l,width:s.width,height:s.height}},[l,s?s.width:null,s?s.height:null])}var G,Rt=h(()=>{G=Ee});import{useMemo as ke}from"../preact@10.5.13/hooks.js";import{scrapboxDOM as $e}from"../scrapbox-dom-accessor/script.js";function Nt({open:e,cursorPosition:t,children:n}){let{ref:r,width:i=0}=G(),{width:s=0}=G({ref:$e.editor}),o=ke(()=>(0,m.toChildArray)(n).length===0,[n]),a=Ie(t),c=je(t,o),l=Me(s,i,t,o);return v <div class="popup-menu" style="${a}" hidden="${!e}">
<div ref="${r}" class="button-container" style="${l}">
${n}
</div>
<div class="triangle" style="${c}" />
</div>}function Me(e,t,n,r){let i=n.styleLeft/e*100,s=20/t*100,o=100-s;return{left:n.styleLeft,transform:translateX(-${Math.max(s,Math.min(i,o))}%),...r?{color:"#eee",fontSize:"11px",display:"inline-block",padding:"0 5px",cursor:"not-allowed",backgroundColor:"#555"}:{}}}var Ie,je,Dt,Tt=h(()=>{I();Rt();Ie=e=>({top:e.styleTop}),je=(e,t)=>({left:e.styleLeft,...t?{borderTopColor:"#555"}:{}});Dt=()=>v<style>
.popup-menu {
position:absolute;
left:0;
width:100%;
z-index:300;
transform:translateY(calc(-100% - 14px));
-webkit-user-select:none;
user-select:none;
font-family:"Open Sans",Helvetica,Arial,"Hiragino Sans",sans-serif;
pointer-events:none
}
.popup-menu .button-container {
position:relative;
display:inline-block;
max-width:70vw;
min-width:80px;
text-align:center;
background-color:#111;
padding:0 1px;
border-radius:4px;
pointer-events:auto
}
max-width:90vw
}
max-width:90vw
}
.popup-menu .triangle {
position:absolute;
transform:translateX(-50%);
width:0;
height:0;
border-top:6px solid #111; border-left:8px solid transparent;
border-right:8px solid transparent
}
max-width:80vw;
text-align:left
}
.button {
font-size:11px;
color:#eee;
cursor:pointer;
display:inline-block;
padding:0 5px
}
.button:not(:first-of-type) {
border:0;
border-left:1px solid #eee }
.button.selected {
background-color:#222;
text-decoration:underline
}
font-size:13px;
padding:6px;
min-width:12vw
}
font-size:13px;
padding:6px;
min-width:12vw
}
.button div.icon {
height:2em;
max-width:10em;
display:inline-block;
overflow:hidden;
margin-left:1px;
vertical-align:top
}
.button div.icon img {
max-height:100%;
vertical-align:unset
}
font-size:11px;
display:block;
line-height:1.2em;
padding:12px 10px;
min-width:40px;
border-left:0
}
border:0;
border-bottom:1px solid #eee }
max-width:80vw;
text-align:left
}
font-size:11px;
display:block;
line-height:1.2em;
padding:12px 10px;
min-width:40px;
border-left:0
}
htmldata-os*='ios' .popup-menu.vertical .button-container .button:not(:last-of-type), .popup-menudata-os*='ios'.vertical .button-container .button:not(:last-of-type) { border:0;
border-bottom:1px solid #eee }
</style>});function J(){return(J=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function _e(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(r,i){if(r==null)return{};var s,o,a={},c=Object.keys(r);for(o=0;o<c.length;o++)i.indexOf(s=c[o])>=0||(a[s]=r[s]);return a}(e,["context","children"]);return(0,m.cloneElement)(t,n)}function Le(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=(0,m.h)(_e,J({},this._props,{context:e.detail.context}),function t(n,r){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var i=[],s={},o=0,a=n.attributes,c=n.childNodes;for(o=a.length;o--;)a[o].name!=="slot"&&(s[a[o].name]=a[o].value,s[At(a[o].name)]=a[o].value);for(o=c.length;o--;){var l=t(c[o],null),d=c[o].slot;d?s[d]=(0,m.h)(Ut,{name:d},l):i[o]=l}var p=r?(0,m.h)(Ut,null,i):i;return(0,m.h)(r||n.nodeName.toLowerCase(),s,p)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?m.hydrate:m.render)(this._vdom,this._root)}function At(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function Be(e,t,n){if(this._vdom){var r={};r[e]=n=n??void 0,r[At(e)]=n,this._vdom=(0,m.cloneElement)(this._vdom,r),(0,m.render)(this._vdom,this._root)}}function Oe(){(0,m.render)(this._vdom=null,this._root)}function Ut(e,t){var n=this;return(0,m.h)("slot",J({},e,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(i){i.stopPropagation(),i.detail.context=t},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Kt(e,t,n,r){function i(){var s=Reflect.construct(HTMLElement,[],i);return s._vdomComponent=e,s._root=r&&r.shadow?s.attachShadow({mode:"open"}):s,s}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=Le,i.prototype.attributeChangedCallback=Be,i.prototype.disconnectedCallback=Oe,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),i.observedAttributes=n,n.forEach(function(s){Object.defineProperty(i.prototype,s,{get:function(){return this._vdom.props[s]},set:function(o){this._vdom?this.attributeChangedCallback(s,null,o):(this._props||(this._props={}),this._props[s]=o,this.connectedCallback());var a=typeof o;o!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(s,o)}})}),customElements.define(t||e.tagName||e.displayName||e.name,i)}var Ht=h(()=>{I()});import{useEffect as Pe}from"../preact@10.5.13/hooks.js";var Ft,zt=h(()=>{Ft=(e,t,n)=>Pe(()=>{let r=new MutationObserver(i=>{r.disconnect(),t(i);for(let s of e)s.current&&r.observe(s.current,n)});for(let i of e)i.current&&r.observe(i.current,n);return()=>r.disconnect()},[])});function Wt(e,t=0){if(typeof e!="function")throw new Error("argument is not function.");let n,r=!1,i=t>0?()=>new Promise(o=>setTimeout(()=>o(),t)):()=>{},s=async()=>{if(await i(),!n){r=!1;return}n.resolve({result:await e(...n.parameters),executed:!0}),n=void 0,await s()};return(...o)=>new Promise(async a=>{if(r){n?.resolve?.({executed:!1}),n={parameters:o,resolve:a};return}r=!0,a({result:await e(...o),executed:!0}),await s()})}var Xt=h(()=>{});var Re={};import{useState as qt}from"../preact@10.5.13/hooks.js";var Se,Gt=h(()=>{I();Pt();Tt();Ht();zt();Xt();Se=()=>{let{ref:e,error:t,setFormula:n}=Ot(""),[r,i]=qt(!1),[s,o]=qt({styleTop:0,styleLeft:0}),a=Wt(c=>{let l=c.target,{top:d,left:p,width:u,height:f}=l.getBoundingClientRect(),b=document.elementsFromPoint(p+u/2,d+f/2).find(Qt=>Qt.classList.contains("formula"));if(!b){i(!1);return}i(!0),n(b.textContent.slice(3,-1));let{top:j}=document.getElementById("editor").getBoundingClientRect(),{top:M}=b.getBoundingClientRect();o({styleTop:M-j,styleLeft:+l.style.left.slice(0,-2)})},100);return Ft([{current:document.getElementById("text-input")}],([c])=>a(c),{attributes:!0}),v
<${Dt} />
<style>
.error {color:#fd7373; }
.katex-display {
display: inline-block !important;
margin: 0 !important;
text-align: inherit !important;
}
</style>
<${Nt} cursorPosition="${s}" open="${r}">
${t&&v<span class="error">${t}</span>}
<span class="katex-display" ref="${e}" />
<//>
};Kt(Se,"userscript-katex-previewer",[],{shadow:!0});document.getElementById("editor").insertAdjacentHTML("beforeend","<userscript-katex-previewer></userscript-katex-previewer>")});var Y=class{constructor(){this._mappings=[],this.started=!1}start(){this.started||(document.addEventListener("keydown",t=>{let n=document.getElementsByClassName("popup-menu")?.[0]?.getElementsByClassName("button");if(!!n)for(let{key:r,shiftKey:i,ctrlKey:s,altKey:o,buttonName:a}of this._mappings){if(t.key!==r||t.shiftKey!==i||t.ctrlKey!==s||t.altKey!==o)continue;let c=[...n].find(l=>l.textContent===a);if(!!c){t.preventDefault(),t.stopPropagation(),c.click();return}}}),this.started=!0)}push(...t){for(let{key:n,shiftKey:r,ctrlKey:i,altKey:s,buttonName:o}of t)this._mappings.push({key:n,shiftKey:r??!1,ctrlKey:i??!1,altKey:s??!1,buttonName:o})}pop(...t){for(let{key:n,shiftKey:r,ctrlKey:i,altKey:s,buttonName:o}of t){let a=this._mappings.findIndex(c=>c.key===n&&c.shiftKey===(r??!1)&&c.ctrlKey===(i??!1)&&c.altKey===(s??!1)&&c.buttonName===bottonName);a!==-1&&(delete this,_mapping[a])}}},B=new Y;async function Q(e,t=[]){let n=e.match(/https?:\/\/\S+/g)??[];if(n.length===0)return;let r=await Promise.all(n.map(o=>oe(o,t))),i={};for(let o=0;o<n.length&&r[o];o++)i[n[o]]=r[o];return e.replace(/https?:\/\/\S+/g,o=>i[o]??o)}async function oe(e,t){if(!window.fetchURLInfo){alert('Please install "fetchURLInfo" from https://scrapbox.io/programming-notes/url-info-proxy');return}let n=fetchURLInfo(e),r=new URL(e),i=r.hash!==""?decodeURIComponent(r.hash).slice(1):"",s=${r.origin}${r.pathname}${r.search},{title:o,meta:a,DOM:c}=await fetchURLInfo(s,{DOM:!0});return(t.find(({match:l})=>l.test(e))?.text??ie)({url:e,pureURL:s,title:o,hash:i,meta:a,dom:c})}var O=e=>e.trim().replace(/[\n\r\f]/g,"").replace(" ?[","\uFF3B").replace("] ?","\uFF3D");function ie({url:e,title:t,hash:n,dom:r}){if(!t)return e;let i=r.getElementById(n)?.textContent;return i?${e} ${O(i)} | ${O(t)}:${e} ${O(t)}}P();var Z=(e=[])=>scrapbox.PopupMenu.addButton({title:t=>/https?:\/\/\S+/.test(t)?"URL":".",onClick:t=>{if(!/https?:\/\/\S+/.test(t))return;let n=document.getElementById("text-input");return Q(t,e).then(r=>k({text:r,cursor:n})),""}});var S=class{constructor({id:t,maxHeight:n="calc(50vh - 100px)"}={}){this.box=document.createElement("div"),this.box.setAttribute("id",t),this.box.classList.add("form-group"),this.box.style.position="absolute",this.container=document.createElement("div"),this.container.classList.add("dropdown"),this.box.appendChild(this.container),this.items=document.createElement("ul"),this.items.classList.add("dropdown-menu"),this.items.style.whiteSpace="nowrap",this.items.style.maxHeight=n,this.items.style.maxWidth="calc(-100px + 50vw)",this.items.style.overflow="auto",this.container.appendChild(this.items),this.editor=document.getElementById("editor"),this.editor.appendChild(this.box),this.SEED=new Date().getTime().toString(16)}open(){this.length!=0&&this.container.classList.add("open")}close(){!this.isOpen()||(this.container.classList.remove("open"),this.items.textContent="",document.getElementById("text-input").focus())}isOpen(){return this.container.classList.contains("open")}get length(){return this.items.children.length}_makeId(t){returnitem-${this.SEED}-${t}}appendItems(t){t.forEach((n,r)=>{this.items.appendChild(this._makeNewItem({elements:n.elements,onComfirm:n.onComfirm,index:r}))})}resetItems(t){this.items.textContent="",this.appendItems(t)}_makeNewItem({elements:t,onComfirm:n,index:r}){let i=document.createElement("li");i.classList.add("dropdown-item");let s=document.createElement("a");return s.setAttribute("id",this._makeId(r)),s.dataset.index=r,s.setAttribute("tabindex","-1"),t.forEach(o=>s.appendChild(o)),s.onclick=n,i.appendChild(s),i}getItem(t){let n=this._makeId(t),r=document.getElementById(n);if(!!r)return r}get firstItem(){return this.getItem(0)}get lastItem(){return this.getItem(this.length-1)}reDraw(t){this.box.style.top=${parseInt(t.style.top)+parseInt(t.style.height)+3}px,this.box.style.left=${parseInt(t.style.left)}px}get focusedItem(){return this.items.querySelector(":focus")}hasFocus(){return this.focusedItem!=null}selectFirstItem(){this.firstItem.focus()}selectLastItem(){this.lastItem.focus()}hasFirstItemFocus(){return document.activeElement==this.firstItem}hasLastItemFocus(){return document.activeElement==this.lastItem}selectNextItem({wrap:t=!1}={}){let n=this.focusedItem;if(!n){this.selectFirstItem();return}if(n==this.lastItem){t&&this.selectFirstItem();return}this.getItem(this.indexOfFocusedItem+1).focus()}selectPreviousItem({wrap:t=!1}={}){let n=this.focusedItem;if(!n){this.selectLastItem();return}if(n==this.firstItem){t&&this.selectLastItem();return}this.getItem(this.indexOfFocusedItem-1).focus()}get indexOfFocusedItem(){let t=this.focusedItem;if(!!t)return parseInt(t.dataset.index)}};var R=class{constructor(t,{trigger:n}={}){this.raw=void 0,this.target=void 0,this.editor=t,this.trigger=n}reload(t){if(editor.getElementsByClassName("cursor-line").length==0)return!1;let n=this.raw;return this.raw=this._getLinkIncludingCursor(t),this.target=this.raw?.replace(/\[(.*)\]/,"$1"),n!==this.raw}_getLinkIncludingCursor(t){let n=editor.getElementsByClassName("cursor-line")[0];if(!n)return;let r=[...n.getElementsByClassName("page-link")],i=o=>o.getBoundingClientRect().left-n.getBoundingClientRect().left;return r.find(o=>{if(!this.trigger.test(o.textContent.replace(/\[(.*)\]$/,"$1")))return!1;let a=i(o.firstElementChild),c=i(o.lastElementChild),l=parseInt(t.style.left);return a<=l&&l<=c})?.innerText}};var N=class{constructor(t){this._worker=new Worker(t),this._isRunning=!1,this._resetBuffer()}postMessage(t,n=[]){if(this._isRunning){this._buffer.message=t,this._buffer.transfer=n;return}this._worker.postMessage(t,n),this._isRunning=!0}addEventListener(t,n){this._worker.addEventListener(t,r=>{if(n(r),this._buffer.message){this._worker.postMessage(this._buffer.message,this._buffer.transfer),this._resetBuffer();return}this._isRunning=!1})}_resetBuffer(){this._buffer={message:void 0,transfer:void 0}}};import{scrapboxDOM as ae}from"../scrapbox-dom-accessor/script.js";function tt(e){let t=ae.textInput;t.focus(),t.value=typeof e=="object"?e.text:e;let n=document.createEvent("UIEvent");n.initEvent("input",!0,!1),t.dispatchEvent(n)}import{scrapboxDOM as st}from"../scrapbox-dom-accessor/script.js";var et=(e,t)=>[...Array(t+1).keys()].slice(e,t+1),D={Backspace:8,Tab:9,Enter:13,Delete:46,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,...Object.fromEntries(et("a".charCodeAt(0),"z".charCodeAt(0)).flatMap((e,t)=>[[String.fromCodePoint(e),65+t],[String.fromCodePoint(e).toUpperCase(),65+t]])),...Object.fromEntries([...Array(10).keys()].map(e=>[e,e+48])),...Object.fromEntries(et(1,12).map(e=>[F${e},112+e])),":":186,"*":186,";":187,"+":187,"-":189,"=":189,".":190,">":190,"/":191,"?":191,"@":192,"":192,"":219,"{":219,"\\":220,"|":220,"":221,"}":221,"^":222,"~":222,_:226};var nt=(e,t)=>...Array(t+1).keys().slice(e,t+1),T=Object.fromEntries(nt("!".charCodeAt(0),"~".charCodeAt(0)).flatMap(e=>{let t=String.fromCodePoint(e);return t==="<"?"<","\\<":t==="\\"?"\\","\\\\":t,t})),A={Backspace:"BS",Enter:"CR",Delete:"Del",Escape:"Esc"," ":"Space",ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",...Object.fromEntries(["Tab","PageUp","PageDown","End","Home",...nt(1,12).map(e=>F${e+1})].map(e=>e,e))},Ze={...A,...T},rt={0:"LeftMouse",1:"MiddleMouse",2:"RightMouse"};var nn=U(rt),rn=U(T),sn=U(A);function U(e){return Object.fromEntries(Object.entries(e).map(t=>t.reverse()))}function K(e,{shiftKey:t=!1,ctrlKey:n=!1,altKey:r=!1,noKey:i=!1}={}){if(!(e in D))throw Error(No key code of ${e});let s={bubbles:!0,cancelable:!0,keyCode:De,shiftKey:t,ctrlKey:n,altKey:r};st.textInput.dispatchEvent(new KeyboardEvent("keydown",s)),st.textInput.dispatchEvent(new KeyboardEvent("keyup",s))}var ot=class{get editor(){return document.getElementById("editor")}get lines(){return document.getElementsByClassName("lines")?.0}get computeLine(){return document.getElementById("compute-line")}get grid(){return document.getElementsByClassName("related-page-list clearfix")?.0?.getElementsByClassName("grid")?.0}get cursorLine(){return document.getElementsByClassName("cursor-line")?.0}get textInput(){return document.getElementById("text-input")}get cursor(){return document.getElementsByClassName("cursor")?.0}get selections(){return document.getElementsByClassName("selections")?.0}get popupMenu(){return document.getElementsByClassName("popup-menu")?.0}get pageMenus(){return document.getElementsByClassName("page-menu")?.0}get pageInfoMenu(){return document.getElementById("page-info-menu")}get pageEditMenu(){return document.getElementById("page-edit-menu")}get pageEditButtons(){return this.pageEditMenu.nextElementSibling.getElementsByTagName("a")}get randomJumpButton(){return document.getElementsByClassName("random-jump-button")?.0}get pageCustomButtons(){return document.getElementsByClassName("page-menu-extension")}},it=new ot;var at='spanclass^="c-"',C=class{constructor({charDOM:t}){if(!t?.matches?.(at))throw Error(${t} is not span.c-*.);this.charDOM=t}get index(){return parseInt(this.charDOM.className.replace(/c-(\d+)/,"$1"))}get text(){return this.charDOM.textContent}get line(){return this.charDOM.closest("div.line")}get isHead(){return this.index===0}get isEnd(){return this._chars.pop().className===this.charDOM.className}get next(){if(this.isHead)return;let t=this.line.getElementsByClassName(c-${this.index+1})?.0;return new C({charDOM:t})}get prev(){if(this.isEnd)return;let t=this.line.getElementsByClassName(c-${this.index-1})?.0;return new C({charDOM:t})}get link(){if(this.charDOM.closest("a"))return{type:internalLink.type,href:internalLink.href,dom:internalLink};let n=this.charDOM.closest("span.link");if(n){letr,i=n.textContent.replace(/\(.+?)\/,"$1").split(/\s/);return{type:"link",href:i,text:r}}}get _chars(){return...this.line.querySelectorAll(at)}},H=e=>e?new C({charDOM:e}):void 0;function ct({x:e,y:t}){let n=ce({y:t});if(!n)return{message:"No line found."};let r=[...n.querySelectorAll('spanclass^="c-"')],{top:i,left:s,height:o}=n.getBoundingClientRect(),a=n.clientHeight,c=Math.floor((t-i)/a),l=o>a?r.filter(u=>{let f=u.getBoundingClientRect().top;return i+c*a<=f&&f<i+(c+1)*a}):r;if(l.length===0)return{line:n,message:"No char found"};let p=[...l.map((u,f,g)=>({left:f===0?void 0:gf-1,right:u})),{left:l.pop(),right:void 0}].find(({left:u,right:f})=>{let g=u?.getBoundingClientRect?.()??f.getBoundingClientRect(),b=f?.getBoundingClientRect?.()??u.getBoundingClientRect(),j=(u?g.left:g.left-g.width)+g.width/2,M=(f?b.left:b.right)+b.width/2;return j<=e&&e<M})??{message:"No border matched."};return{line:n,...p}}function ce({y:e}){return...it.lines.children.find(t=>{let n=t.getBoundingClientRect();return n.top<=e&&e<n.bottom})}import{scrapboxDOM as F}from"../scrapbox-dom-accessor/script.js";var z=()=>{let e=F.editor.getBoundingClientRect(),t=e.left+parseInt(F.cursor.style.left),n=e.top+parseInt(F.cursor.style.top),{left:r,right:i,line:s,message:o}=ct({x:t,y:n});if(o)return{line:s,message:o};let a=i?H(i).index:H(r).index+1;return{left:r,right:i,line:s,index:a}};import{scrapboxDOM as W}from"../scrapbox-dom-accessor/script.js";var w=class{constructor({lineDOM:t,id:n,index:r}){if(r!==void 0&&(n=scrapbox.Page.linesr?.id,n===void 0))throw Error(${r} is out of range);if(n!==void 0&&(t=document.getElementById(n),!t))throw Error(${n} is an invalid line id.);if(!t?.classList?.contains?.("line")||t?.tagName!=="DIV")throw Error(${t} is not div.line);this.lineDOM=t}get index(){return...W.lines.children.indexOf(this.lineDOM)}get id(){return this.lineDOM.id}get text(){return scrapbox.Page.linesthis.index?.text}get breakNum(){return Math.floor(this.lineDOM.getBoundingClientRect().height/this.lineDOM.clientHeight)}charDOM(t){return this.lineDOM.getElementsByClassName(c-${t})?.0}get charDOMs(){return[...this.lineDOM.querySelectorAll('spanclass^="c-"')]}get headCharDOM(){return this.charDOM(0)}get lastCharDOM(){let t=this.text.length-1;return this.charDOM(t<0?0:t)}get headNonBlankCharDOM(){let t=this.text;if(/^\s+$/.test(t))return this.lastCharDOM;if(!/^\s+/.test(t))return this.headCharDOM;let n=t.match(/^\s+/)?.0.length;return this.charDOM(n)}get lastNonBlankCharDOM(){let t=this.text;if(/^\s+$/.test(t))return this.headCharDOM;if(!/\s+$/.test(t))return this.lastCharDOM;let n=t.match(/\s+$/)?.0.length;return this.charDOM(this.text.length-1-n)}get prevDOM(){this.lineDOM.previousElementSibling}get nextDOM(){this.lineDOM.nextElementSibling}get prev(){let t=this.prevDOM;return t?new w({lineDOM:t}):void 0}get next(){let t=this.nextDOM;return t?new w({lineDOM:t}):void 0}get isHead(){return W.lines.firstElementChild.id===this.lineDOM.id}get isLast(){return W.lines.lastElementChild.id===this.lineDOM.id}_log(t,...n){if(n.length>0){console.log([scrapbox-line-info-2] ${t},n);return}console.log([scrapbox-line-info-2] ${t})}},lt=(e,t=void 0,n=void 0)=>n!==void 0?new w({index:n}):t!==void 0?new w({id:t}):e?new w({lineDOM:e}):void 0;var ut=()=>/mobile/i.test(navigator.userAgent);var X=class{constructor({id:t,projects:n=[],projects_lazy:r=[],includeYourProject:i,maxSuggestionNum:s,maxHeight:o,trigger:a,makeRaw:c,searchWorkerCode:l,enableOnMobile:d=!1,disableKeybindings:p=!1}){if(document.getElementById(t)||!d&&ut()){this.alreadyExists=!0;return}this.alreadyExists=!1,this.isCompletioning=!1,this._disableKeyBindings=p,this._disableCompletion=!1,this.window=new S({id:t,maxHeight:o}),this.observer=new R(this.window.editor,{trigger:a}),i?(this.projects=[...new Set(...n,scrapbox.Project.name)],this.projects_lazy=...new Set(r)):(this.projects=...new Set(n.filter(u=>u!=scrapbox.Project.name)),this.projects_lazy=...new Set(r.filter(u=>u!=scrapbox.Project.name))),this.searchWorker=new N(l),this.maxSuggestionNum=s,this.matchedList=[],this.logHeadString=t}start(){this.alreadyExists||(this._importDataList(),this.window.editor.addEventListener("keyup",t=>this._keyupEventHandler(t)),this.window.editor.addEventListener("mouseup",t=>this._keyupEventHandler(t)),this.window.editor.addEventListener("keydown",t=>this._keydownEventHandler(t)),this.searchWorker.addEventListener("message",t=>this._updateList(t)))}_startCompletion(t){this.isCompletioning=!0,this.matchedList.length!==0&&(this.window.reDraw(t),this.window.open())}_stopCompletion(t){this.isCompletioning=!1,this.window.close()}async _importDataList(){}_keyupEventHandler(t){if(!t.key&&t.button===void 0||this._disableCompletion)return;if(this._isInCodeBlock()){this._stopCompletion();return}switch(t.key){case"Escape":case"Home":case"End":case"PageUp":case"PageDown":this._stopCompletion();return}let n=document.getElementById("text-input");if(this.observer.reload(n)){if(!this.observer.target){this._stopCompletion();return}this._log("target: %o",this.observer.target),this._postMessage(this.observer.target)}if(!this.observer.target){this._stopCompletion();return}if(!(!this.isCompletioning&&!t.key)&&!(!this.isCompletioning&&!t.key.match(/^.$/)&&t.key!=="Backspace")){if(this.window.length==1&&this.window.hasFocus()&&!this._disableKeyBindings){this.focusedItem.click();return}this._startCompletion(n)}}_keydownEventHandler(t){if(!this._disableCompletion&&!!t.key&&!!this.window.isOpen()){if(this.matchedList.length==0){this.window.close();return}if(t.key.match(/^.$/)&&this.window.hasFocus()){document.getElementById("text-input").focus();return}if(!this._disableKeyBindings){if(t.key=="Tab"&&t.shiftKey||t.key=="ArrowUp"&&this.window.hasFocus()){t.stopPropagation(),t.preventDefault(),this.window.selectPreviousItem({wrap:!0});return}if(t.key=="Tab"||t.key=="ArrowDown"&&this.window.hasFocus()){t.stopPropagation(),t.preventDefault(),this.window.selectNextItem({wrap:!0});return}if(t.key=="Enter"){t.stopPropagation(),t.preventDefault(),this.window.hasFocus()?this.window.focusedItem.click():this.window.firstItem.click();return}}}}_updateList(t){if(!t.data||(this.matchedList=t.data,this.window.resetItems(this._createGuiList(this.matchedList)),!this.isCompletioning))return;let n=document.getElementById("text-input");this._startCompletion(n)}_createGuiList(t){}_comfirm(t,n){let r=z(),i=r.index,s=lt(r.line).text.lastIndexOf("[",i),o=this.observer.raw.length;console.log({index:s,length:o});for(let a=z().index;a>s;a--)K("ArrowLeft");for(let a=0;a<o;a++)K("ArrowRight",{shiftKey:!0});tt({text:n}),this._stopCompletion()}_postMessage(t){}_isInCodeBlock(){let t=this.window.editor.getElementsByClassName("cursor-line")0;return t?t.getElementsByClassName("code-block").length==1:!1}_log(t,...n){console.log([${this.logHeadString}] ${t},n)}};var q=class extends X{constructor({projects:t,includeYourProject:n=!0,maxSuggestionNum:r=30,maxHeight:i="calc(50vh - 100px)",enableOnMobile:s=!1}={}){super({id:"emoji-completion",projects:t,includeYourProject:n,maxSuggestionNum:r,maxHeight:i,trigger:/^:/,makeRow:o=>o.substr(2,o.length-3),searchWorkerCode:"/api/code/yosider-scripts/\u5916\u90E8\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306Eicon\u3092\u88DC\u5B8C\u3059\u308BUserScript/searchWorker.js",enableOnMobile:s})}async _importDataList(){this.searchWorker.postMessage({loading:!0,projects:this.projects})}_createGuiList(t){let n=document.getElementById("text-input");return t.map(r=>{let i=document.createElement("div");i.textContent=/${r.project}/${r.name};let s=document.createElement("img");s.src=/api/pages/${r.project}/${encodeURIComponent(r.name)}/icon,s.classList.add("icon"),s.style.height="17px",s.style.float="left";let o=[${scrapbox.Project.name!==r.project?"/"+r.project+"/":""}${r.name}.icon];return new Object({elements:s,i,onComfirm:()=>this._comfirm(n,o)})})}_postMessage(t){this.searchWorker.postMessage({word:t,maxSuggestionNum:this.maxSuggestionNum})}};B.start();B.push({key:"t",buttonName:"\uF099"},{key:"]",buttonName:"\uF127"},{key:"o",buttonName:"OGP"},{key:"c",buttonName:"Copy plain"},{key:"u",buttonName:"URL"});$("body").attr("data-daiiz-rel-bubble","on");$("body").attr("data-daiiz-text-bubble","on");var Jt=e=>e.trim().replace(/\n\r\f/g,"").replace(" ?","\uFF3B").replace(" ?","\uFF3D");Z([{match:/https:\/\/qiita\.com/,text:({url:e,title:t,meta:n,dom:r,hash:i})=>{console.log({url:e,title:t,hash:i});let s=r.getElementById(i);if(!s)return[${e} ${t}];let o=s.parentNode.textContent;return[${e} ${Jt(o)} | ${Jt(t)}]}}]);Promise.resolve().then(()=>ht());Promise.resolve().then(()=>L(gt()));Promise.resolve().then(()=>L(bt()));var Ne=new q({projects:"icons","emoji","icons2"});Ne.start();(async()=>{let{execute:e}=await Promise.resolve().then(()=>(wt(),yt));e("coils","AGI","villagepump","programming-notes","yosider-scripts")})();scrapbox.PopupMenu.addButton({title:"OGP",onClick:e=>[https://ricapitolare.vercel.app/svg?url=${e}#.svg ${e}]});Promise.resolve().then(()=>L(Et()));Promise.resolve().then(()=>Gt());function De(){let e=[],t=0;for(let n of document.querySelectorAll(".deco-\\=")){let r=n.innerText;if(r.match(/=/))e.push(decodeURI(r.replace(/[/g,"").replace(/]/g,""))+";");else{let i=!1;for(let s of n.children){let o=scrapcalc_element_id_${t};s.id=o,i?e.push(document.getElementById("${o}").innerHTML = "";):(i=!0,e.push(document.getElementById("${o}").innerHTML = "<span style='font-style:italic;font-weight:bold;'>"+(${decodeURI(r.replace(/[/g,"[").replace(/]/g,"]"))})+"</span>";)),t+=1}}}return e.join(` )}scrapbox.PageMenu.addMenu({title:"ScrapCalc",image:"https://gyazo.com/5441ee8eb0bf51650a91751e48669c21/thumb/48",onClick:()=>{Function((() => {${De()}})();)()}});var Vt="Jump to an unread page";scrapbox.PageMenu.addMenu({title:Vt,image:"https://gyazo.com/f74d4fc373248fb2abac31ff1f69b482/raw",onClick:async()=>{let e=scrapbox.Project.name,t=scrapbox.Project.pages.filter(s=>s.exists&&s.title!==scrapbox.Page.title),n=async()=>{let s=t[Math.floor(Math.random()*t.length)].title;return await(await fetch(/api/pages/${e}/${encodeURIComponent(s)})).json()},r=scrapbox.PageMenu(Vt);r.removeAllItems(),r.emitChange();let i=0;for(;;){let s=await n(),o=${++i}: /${e}/${s.title};r.addItem({title:o,onClick:()=>{}}),console.log(o);let a=s.lines.find(c=>s.lastAccessed<c.updated);if(a){let c=document.createElement("a");c.href=./${encodeURIComponent(s.title)}#${a.id},c.rel="route",document.body.appendChild(c),c.click(),c.remove();return}}}});var Yt=({image:e,...t})=>scrapbox.PageMenu.addMenu({title:send to ${t.project},image:e,onClick:()=>Te({...t})});async function Te({project:e,privateTag:t,useSendingMark:n,useReferenceMark:r}){let i=scrapbox.Page.title,s=encodeURIComponent(scrapbox.Page.title),a=await(await fetch(/api/pages/${scrapbox.Project.name}/${s})).json();if(t&&a.links.includes(t)){let u=This page contains #${t}! Aborted.;throw alert(u),new Error(u)}let c=a.lines.length,l=new RegExp((?:sent\\sto|from)\\s\\[\\/${e}\\/${i.replace(/[.*+?^=!:${}()|\\/\\]/g,"\\$&")}\\]);a.lines=a.lines.filter(u=>!l.test(u.text.trim()));let d={pages:[a]},p=new FormData;p.append("import-file",new Blob([JSON.stringify(d)],{type:"application/json"})),await fetch(/api/page-data/import/${e}.json,{method:"POST",headers:{"X-CSRF-TOKEN":window._csrf},body:p}),r?window.open(https://scrapbox.io/${e}/${s}?body=${encodeURIComponent(`from /${scrapbox.Project.name}/${i} )}):window.open(https://scrapbox.io/${e}/${s}),n&&c==a.lines.length&&window.open(https://scrapbox.io/${scrapbox.Project.name}/${s}?body=${encodeURIComponent(sent to /${e}/${i}